#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int n, star;
	scanf("%d%d",&n,&star);
	int nums[30] = { 0 };
	for (int i = 0; i < n; i++)
	{
		nums[i] = star + i * 2;
	}
	int ret = nums[0];
	for (int j = 1; j < n; j++)
	{
		ret ^= nums[j];
	}
	printf("%d", ret);
	return 0;
}